export const namespace = "stadiumPayrollSet";
import record from "@/pages/marketing/record";
import { Image } from "antd";

export const calcColumns = (params) => {
  const { operate, venueArr } = params;
  let enumlist = {};
  venueArr.forEach((v) => {
    enumlist[v.id] = {
      text: v.venueName,
    };
  });
  const columns = [
    {
      title: "手机号码",
      dataIndex: "phonenumber",
    },
    {
      title: "员工姓名",
      dataIndex: "nickName",
    },
    {
      dataIndex: "venueId",
      title: "所属场馆",
      valueEnum: enumlist,
      hideInSearch: true,
    },

    {
      title: "基本工资",
      dataIndex: "salaryTypeJson",
      hideInSearch: true,
      render: (_, record) => {
        if (record.salaryTypeJson) {
          let salaryTypeJsons = JSON.parse(record.salaryTypeJson).filter(
            (salaryType) => salaryType.salary_type_name == "基本工资"
          );
          return (
            <span>
              {salaryTypeJsons.length ? salaryTypeJsons[0].values : "-"}
            </span>
          );
        } else {
          return null;
        }
      },
    },
    {
      title: "五险一金",
      dataIndex: "salaryTypeJson",
      hideInSearch: true,
      valueType: "money",
      render: (_, record) => {
        if (record.salaryTypeJson) {
          let salaryTypeJsons = JSON.parse(record.salaryTypeJson).filter(
            (salaryType) => salaryType.salary_type_name == "五险一金"
          );
          return (
            <span>
              {salaryTypeJsons.length ? salaryTypeJsons[0].values : "-"}
            </span>
          );
        } else {
          return null;
        }
      },
    },
  ];
  if (params?.operate) {
    columns.push(params?.operate);
  }
  return columns;
};
